package com.probiz.estore.common.model.product.base;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.apache.commons.lang.builder.ToStringBuilder;

import com.probiz.estore.common.model.attribute.AttributeValue;
import com.probiz.estore.common.model.attribute.ProductAttrValue;
import com.probiz.estore.common.model.catalog.ProductCategory;
import com.probiz.estore.common.model.product.Brand;
import com.probiz.estore.common.model.product.ProductDescription;
import com.probiz.estore.common.model.product.ProductMedia;
import com.probiz.estore.common.model.product.ProductReview;
import com.probiz.estore.common.model.product.ProductSku;
import com.probiz.estore.common.model.product.ProductStat;
import com.probiz.estore.common.model.product.ProductType;
import com.probiz.estore.common.model.product.StockNotify;
import com.probiz.estore.common.model.sales.AlsoBuy;
import com.probiz.estore.common.model.sales.RecommendedProduct;
import com.probiz.estore.core.model.BaseObject;

/**
 * Product Base Java Bean, base class for the model, mapped directly to database table
 * <p/>
 * Avoid changing this file if not necessary, will be overwritten.
 */
public class ProductTbl extends BaseObject implements Serializable {
    protected Integer productId;
    protected String productName;
    protected String productCode;
    protected String title;
    protected String metaKeyword;
    protected String metaDescription;
    protected Short productKind;    //1=商品 2=商品包
    protected Integer minOrderQuantity;
    protected Integer maxOrderQuantity;
    protected BigDecimal price;
    protected String keywords;
    protected Date shelveTime;
    protected Date offshelveTime;
    protected String displayFlag;
    protected String imageUrl;
    protected Date createTime;
    protected Date updateTime;
    protected String templatePath;
    protected Integer version;
    protected Short status;
    protected Integer sortOrder;
    protected Short isSetMultiSkus;
    protected String salesMeasureUnitName;
    protected String weightMeasureUnitName;
    protected BigDecimal taxRate;
    protected String tags;

    protected Brand brand;
    protected ProductType productType;
    protected ProductDescription productDescription;
    protected ProductStat productStat;
    protected ProductSku defaultProductSku;
    protected ProductCategory category;

    protected Set<ProductAttrValue> productAttrValues = new HashSet<ProductAttrValue>();
    protected Set<ProductMedia> productMedias = new HashSet<ProductMedia>();
    protected Set<ProductReview> productReviews = new HashSet<ProductReview>();
    protected Set<ProductSku> productSkus = new HashSet<ProductSku>();
    protected Set<RecommendedProduct> recommendedProducts = new HashSet<RecommendedProduct>(); //关联的推荐商品
    protected Set<RecommendedProduct> paRecommendedProducts = new HashSet<RecommendedProduct>(); //被关联的推荐商品
    protected Set<StockNotify> stockNotifys = new HashSet<StockNotify>();
    protected Set<AlsoBuy> alsoBuySourceProducts  = new HashSet<AlsoBuy>(); 
    //用于导入货品使用
    protected ProductSku importProductSku;
    protected List<AttributeValue> importAttributeValueList = new ArrayList<AttributeValue>();
    //临时变量 ,用于导入
    boolean isUseSimplePathName = false;
    //临时变量 ,用于决定是导入商品还是货品,默认是商品
    boolean isSkuImportFlag = false;
    

    /**
     * Default Empty Constructor for class Product
     */
    public ProductTbl() {
        super();
    }

    /**
     * Default Key Fields Constructor for class Product
     *
     * @param in_productId 商品id
     */
    public ProductTbl(Integer in_productId) {
        this.setProductId(in_productId);
    }


    public Short getProductKind() {
        return productKind;
    }

    public void setProductKind(Short productKind) {
        this.productKind = productKind;
    }

    public Integer getMaxOrderQuantity() {
        return maxOrderQuantity;
    }

    public void setMaxOrderQuantity(Integer maxOrderQuantity) {
        this.maxOrderQuantity = maxOrderQuantity;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }
    


	public String getKeywords() {
        return keywords;
    }

    public void setKeywords(String keywords) {
        this.keywords = keywords;
    }

    public Date getShelveTime() {
        return shelveTime;
    }

    public void setShelveTime(Date shelveTime) {
        this.shelveTime = shelveTime;
    }

    public Date getOffshelveTime() {
        return offshelveTime;
    }

    public void setOffshelveTime(Date offshelveTime) {
        this.offshelveTime = offshelveTime;
    }

    public String getDisplayFlag() {
        return displayFlag;
    }

    public void setDisplayFlag(String displayFlag) {
        this.displayFlag = displayFlag;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }


    public Brand getBrand() {
        return brand;
    }

    public void setBrand(Brand brand) {
        this.brand = brand;
    }

    public ProductType getProductType() {
        return productType;
    }

    public void setProductType(ProductType productType) {
        this.productType = productType;
    }

    public ProductDescription getProductDescription() {
        return productDescription;
    }

    public void setProductDescription(ProductDescription productDescription) {
        this.productDescription = productDescription;
    }

    public ProductStat getProductStat() {
        return productStat;
    }

    public void setProductStat(ProductStat productStat) {
        this.productStat = productStat;
    }

    public ProductSku getDefaultProductSku() {
        return defaultProductSku;
    }

    public void setDefaultProductSku(ProductSku defaultProductSku) {
        this.defaultProductSku = defaultProductSku;
    }

    public ProductCategory getCategory() {
        return category;
    }

    public void setCategory(ProductCategory category) {
        this.category = category;
    }

    public Set<ProductAttrValue> getProductAttrValues() {
        return productAttrValues;
    }

    public void setProductAttrValues(Set<ProductAttrValue> productAttrValues) {
        this.productAttrValues = productAttrValues;
    }

    public Set<ProductMedia> getProductMedias() {
        return productMedias;
    }

    public void setProductMedias(Set<ProductMedia> productMedias) {
        this.productMedias = productMedias;
    }

    public Set<ProductReview> getProductReviews() {
        return productReviews;
    }

    public void setProductReviews(Set<ProductReview> productReviews) {
        this.productReviews = productReviews;
    }

    public Set<ProductSku> getProductSkus() {
        return productSkus;
    }

    public void setProductSkus(Set<ProductSku> productSkus) {
        this.productSkus = productSkus;
    }
    
    

    public Set<RecommendedProduct> getRecommendedProducts() {
		return recommendedProducts;
	}

	public void setRecommendedProducts(Set<RecommendedProduct> recommendedProducts) {
		this.recommendedProducts = recommendedProducts;
	}

	public Set<RecommendedProduct> getPaRecommendedProducts() {
		return paRecommendedProducts;
	}

	public void setPaRecommendedProducts(
			Set<RecommendedProduct> paRecommendedProducts) {
		this.paRecommendedProducts = paRecommendedProducts;
	}

	public Set<StockNotify> getStockNotifys() {
		return stockNotifys;
	}

	public void setStockNotifys(Set<StockNotify> stockNotifys) {
		this.stockNotifys = stockNotifys;
	}
	
	

	public Set<AlsoBuy> getAlsoBuySourceProducts() {
		return alsoBuySourceProducts;
	}

	public void setAlsoBuySourceProducts(Set<AlsoBuy> alsoBuySourceProducts) {
		this.alsoBuySourceProducts = alsoBuySourceProducts;
	}
	

	public ProductSku getImportProductSku() {
		return importProductSku;
	}

	public void setImportProductSku(ProductSku importProductSku) {
		this.importProductSku = importProductSku;
	}
	

	public List<AttributeValue> getImportAttributeValueList() {
		return importAttributeValueList;
	}

	public void setImportAttributeValueList(
			List<AttributeValue> importAttributeValueList) {
		this.importAttributeValueList = importAttributeValueList;
	}

	public boolean isUseSimplePathName() {
		return isUseSimplePathName;
	}

	public void setUseSimplePathName(boolean isUseSimplePathName) {
		this.isUseSimplePathName = isUseSimplePathName;
	}
	

	public boolean isSkuImportFlag() {
		return isSkuImportFlag;
	}

	public void setSkuImportFlag(boolean isSkuImportFlag) {
		this.isSkuImportFlag = isSkuImportFlag;
	}

	/**
     * * @return Integer
     *
     * @hibernate.id column="productId" type="java.lang.Integer" generator-class="native"
     */
    public Integer getProductId() {
        return this.productId;
    }

    /**
     * Set the productId
     */
    public void setProductId(Integer aValue) {
        this.productId = aValue;
    }

    /**
     * * @return Integer
     */
    public Integer getProductTypeId() {
        return this.getProductType() == null ? null : this.getProductType().getProductTypeId();
    }

    /**
     * Set the productTypeId
     */
    public void setProductTypeId(Integer aValue) {
        if (aValue == null) {
            productType = null;
        } else {
            productType = new com.probiz.estore.common.model.product.ProductType(aValue);
            productType.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
        }
    }

    /**
     * * @return Integer
     */
    public Integer getDefaultProductSkuId() {
        return this.getDefaultProductSku() == null ? null : this.getDefaultProductSku().getProductSkuId();
    }

    /**
     * Set the defaultProductSkuId
     */
    public void setDefaultProductSkuId(Integer aValue) {
        if (aValue == null) {
            defaultProductSku = null;
        } else {
            defaultProductSku = new com.probiz.estore.common.model.product.ProductSku(aValue);
            defaultProductSku.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
        }
    }

    /**
     * * @return Integer
     */
    public Integer getBrandId() {
        return this.getBrand() == null ? null : this.getBrand().getBrandId();
    }

    /**
     * Set the brandId
     */
    public void setBrandId(Integer aValue) {
        if (aValue == null) {
            brand = null;
        } else {
            brand = new Brand(aValue);
            brand.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
        }
    }


    /**
     * * @return Integer
     */
    public Integer getProductDescriptionId() {
        return this.getProductDescription() == null ? null : this.getProductDescription().getProductDescriptionId();
    }

    /**
     * Set the productDescriptionId
     */
    public void setProductDescriptionId(Integer aValue) {
        if (aValue == null) {
            productDescription = null;
        } else {
            productDescription = new ProductDescription(aValue);
            productDescription.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
        }
    }

    public Integer getProductStatId() {
        return this.getProductStat() == null ? null : this.getProductStat().getProductStatId();
    }

    public void setProductStatId(Integer aValue) {
        if (aValue == null) {
            productStat = null;
        } else {
            productStat = new ProductStat(aValue);
            productStat.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
        }
    }

    public Integer getCategoryId() {
        return this.getCategory() == null ? null : this.getCategory().getCategoryId();
    }

    public void setCategoryId(Integer aValue) {
        if (aValue == null) {
            category = null;
        } else {
            category = new ProductCategory(aValue);
            category.setVersion(Integer.valueOf(0));//set a version to cheat hibernate only
        }
    }


   

	/**
     * * @return String
     *
     * @hibernate.property column="productName" type="java.lang.String" length="128" not-null="true" unique="false"
     */
    public String getProductName() {
        return this.productName;
    }

    /**
     * Set the productName
     *
     * @spring.validator type="required"
     */
    public void setProductName(String aValue) {
        this.productName = aValue;
    }

    /**
     * * @return String
     *
     * @hibernate.property column="productCode" type="java.lang.String" length="32" not-null="true" unique="false"
     */
    public String getProductCode() {
        return this.productCode;
    }

    /**
     * Set the productCode
     *
     * @spring.validator type="required"
     */
    public void setProductCode(String aValue) {
        this.productCode = aValue;
    }


    /**
     * seo title	 * @return String
     *
     * @hibernate.property column="title" type="java.lang.String" length="128" not-null="false" unique="false"
     */
    public String getTitle() {
        return this.title;
    }

    /**
     * Set the title
     */
    public void setTitle(String aValue) {
        this.title = aValue;
    }

    /**
     * seo	 * @return String
     *
     * @hibernate.property column="metaKeyword" type="java.lang.String" length="256" not-null="false" unique="false"
     */
    public String getMetaKeyword() {
        return this.metaKeyword;
    }

    /**
     * Set the metaKeyword
     */
    public void setMetaKeyword(String aValue) {
        this.metaKeyword = aValue;
    }

    /**
     * seo	 * @return String
     *
     * @hibernate.property column="metaDescription" type="java.lang.String" length="256" not-null="false" unique="false"
     */
    public String getMetaDescription() {
        return this.metaDescription;
    }

    /**
     * Set the metaDescription
     */
    public void setMetaDescription(String aValue) {
        this.metaDescription = aValue;
    }


    /**
     * 最少订购量	 * @return Integer
     *
     * @hibernate.property column="minOrderQuantity" type="java.lang.Integer" length="10" not-null="true" unique="false"
     */
    public Integer getMinOrderQuantity() {
        return this.minOrderQuantity;
    }

    /**
     * Set the minOrderQuantity
     *
     * @spring.validator type="required"
     */
    public void setMinOrderQuantity(Integer aValue) {
        this.minOrderQuantity = aValue;
    }


    /**
     * * @return java.util.Date
     *
     * @hibernate.property column="createTime" type="java.util.Date" length="0" not-null="true" unique="false"
     */
    public java.util.Date getCreateTime() {
        return this.createTime;
    }

    /**
     * Set the createTime
     *
     * @spring.validator type="required"
     */
    public void setCreateTime(java.util.Date aValue) {
        this.createTime = aValue;
    }

    /**
     * * @return java.util.Date
     *
     * @hibernate.property column="updateTime" type="java.util.Date" length="0" not-null="true" unique="false"
     */
    public java.util.Date getUpdateTime() {
        return this.updateTime;
    }

    /**
     * Set the updateTime
     *
     * @spring.validator type="required"
     */
    public void setUpdateTime(java.util.Date aValue) {
        this.updateTime = aValue;
    }

    /**
     * 显示模版	 * @return String
     *
     * @hibernate.property column="templatePath" type="java.lang.String" length="128" not-null="false" unique="false"
     */
    public String getTemplatePath() {
        return this.templatePath;
    }

    /**
     * Set the templatePath
     */
    public void setTemplatePath(String aValue) {
        this.templatePath = aValue;
    }

    
    public Short getIsSetMultiSkus() {
		return isSetMultiSkus;
	}

	public void setIsSetMultiSkus(Short isSetMultiSkus) {
		this.isSetMultiSkus = isSetMultiSkus;
	}

	/**
     * * @return Integer
     *
     * @hibernate.property column="version" type="java.lang.Integer" length="10" not-null="true" unique="false"
     */
    public Integer getVersion() {
        return this.version;
    }

    /**
     * Set the version
     *
     * @spring.validator type="required"
     */
    public void setVersion(Integer aValue) {
        this.version = aValue;
    }


    public Short getStatus() {
        return this.status;
    }

    public void setStatus(Short status) {
        this.status = status;
    }

    
    public Integer getSortOrder() {
		return sortOrder;
	}

	public void setSortOrder(Integer sortOrder) {
		this.sortOrder = sortOrder;
	}

	public String getSalesMeasureUnitName() {
        return salesMeasureUnitName;
    }

    public void setSalesMeasureUnitName(String salesMeasureUnitName) {
        this.salesMeasureUnitName = salesMeasureUnitName;
    }


    public String getWeightMeasureUnitName() {
        return weightMeasureUnitName;
    }

    public void setWeightMeasureUnitName(String weightMeasureUnitName) {
        this.weightMeasureUnitName = weightMeasureUnitName;
    }


    public BigDecimal getTaxRate() {
        return taxRate;
    }

    public void setTaxRate(BigDecimal taxRate) {
        this.taxRate = taxRate;
    }
    

    public String getTags() {
		return tags;
	}

	public void setTags(String tags) {
		this.tags = tags;
	}

	/**
     * @see java.lang.Object#toString()
     */
    public String toString() {
        return new ToStringBuilder(this)
                .append("productId", this.productId)
                .append("productName", this.productName)
                .append("productCode", this.productCode)
                .append("title", this.title)
                .append("metaKeyword", this.metaKeyword)
                .append("metaDescription", this.metaDescription)
                .append("minOrderQuantity", this.minOrderQuantity)
                .append("productKind", this.productKind)
                .append("createTime", this.createTime)
                .append("updateTime", this.updateTime)
                .append("templatePath", this.templatePath)
                .append("version", this.version)
                .append("status", this.status)
                .toString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ProductTbl that = (ProductTbl) o;

        if (productCode != null ? !productCode.equals(that.productCode) : that.productCode != null) return false;
        if (productId != null ? !productId.equals(that.productId) : that.productId != null) return false;
        if (productName != null ? !productName.equals(that.productName) : that.productName != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = productId != null ? productId.hashCode() : 0;
        result = 31 * result + (productName != null ? productName.hashCode() : 0);
        result = 31 * result + (productCode != null ? productCode.hashCode() : 0);
        return result;
    }

    /**
     * Return the name of the first key column
     */
    public String getFirstKeyColumnName() {
        return "productId";
    }

    /**
     * Return the Id (pk) of the entity, must be Integer
     */
    public Integer getId() {
        return productId;
    }


}